package com.boco.action;

import java.util.ArrayList;
import java.util.List;

import com.boco.dao.GetEMR_MJZSSJLData;
import com.boco.dao.SentData;
import com.boco.entity.EMR_MJZSSJL;

public class InsertEMR_MJZSSJLDataAction {
	public  String insertData(){
		String url = "http://fasong.cdxp.csb/json/dzbl4";
		String resule = null;
		List<EMR_MJZSSJL> list = new ArrayList<EMR_MJZSSJL>();
		list = GetEMR_MJZSSJLData.getData();
		String userName = "dzbl4";
		String password = "322dfbf9048445cabb06cbf24e64cdcf";
		EMR_MJZSSJL temp = null;
		for(int i=0;i<list.size();i++){
			String param = null;
			temp = list.get(i);
			System.out.println(temp.getXM());
			//按照身份证删除已经存在的值。
			param = "{\"SQL\":\"delete  EMR_MJZSSJL where YLJGZZJGDM='"+
					temp.getYLJGZZJGDM()
					+"' and MJZH = '"+temp.getMJZH()+"'"
					+ "\", \"ANNOTION\":\"cdxplogs\"}";
			resule = SentData.sendPost(url, param, userName, password);
			System.out.println("删除结果："+resule);
			param = "{\"SQL\":\"INSERT INTO EMR_MJZSSJL ("
					+ "HZZSYH,"
					+ "YLJGZZJGDM,"
					+ "YLJGMC,"
					+ "MJZH,"
					+ "SSJLLSH,"
					+ "XM,"
					+ "CSRQ,"
					+ "XB,"
					+ "NL,"
					+ "SSDM,"
					+ "SSMC,"
					+ "SSSQDH,"
					+ "SSRQ,"
					+ "SSYSGH,"
					+ "SSYSXM,"
					+ "SSJBDM,"
					+ "SSJBMC,"
					+ "QKYHDJDM,"
					+ "QKYHDJMC,"
					+ "MZYSGH,"
					+ "MZYSMC,"
					+ "MZFFDM,"
					+ "MZFFMC,"
					+ "SSFLDM,"
					+ "SSFLMC,"
					+ "SSKSSJ,"
					+ "SSJSSJ,"
					+ "SSJG,"
					+ "QTYXCZ,"
					+ "ZRLSH,"
					+ "ORGCODE,"
					+ "AREACODE,"
					+ "UPLOADTIME,"
					+ "SOURCEID"
					+ ") VALUES("
					+ "'" + checkStr(temp.getHZZSYH()) + "'," 
					+ "'" + checkStr(temp.getYLJGZZJGDM()) + "'," 
					+ "'" + checkStr(temp.getYLJGMC()) + "'," 
					+ "'" + checkStr(temp.getMJZH()) + "'," 
					+ "'" + checkStr(temp.getSSJLLSH()) + "'," 
					+ "'" + checkStr(temp.getXM()) + "'," 
					+ "to_date('" + checkStr(temp.getCSRQ())+ "','yyyy-MM-dd HH24:mi:ss')," 
					+ "'" + checkStr(temp.getXB()) + "'," 
					+ "'" + checkStr(temp.getNL()) + "'," 
					+ "'" + checkStr(temp.getSSDM()) + "'," 
					+ "'" + checkStr(temp.getSSMC()) + "'," 
					+ "'" + checkStr(temp.getSSSQDH()) + "'," 
					+ "to_date('" + checkStr(temp.getSSRQ()) + "','yyyy-MM-dd HH24:mi:ss')," 
					+ "'" + checkStr(temp.getSSYSGH()) + "'," 
					+ "'" + checkStr(temp.getSSYSXM()) + "'," 
					+ "'" + checkStr(temp.getSSJBDM()) + "'," 
					+ "'" + checkStr(temp.getSSJBMC()) + "'," 
					+ "'" + checkStr(temp.getQKYHDJDM()) + "'," 
					+ "'" + checkStr(temp.getQKYHDJMC()) + "'," 
					+ "'" + checkStr(temp.getMZYSGH()) + "'," 
					+ "'" + checkStr(temp.getMZYSMC()) + "'," 
					+ "'" + checkStr(temp.getMZFFDM()) + "'," 
					+ "'" + checkStr(temp.getMZFFMC()) + "'," 
					+ "'" + checkStr(temp.getSSFLDM()) + "'," 
					+ "'" + checkStr(temp.getSSFLMC()) + "'," 
					+ "to_date('" + checkStr(temp.getSSKSSJ()) + "','yyyy-MM-dd HH24:mi:ss')," 
					+ "to_date('" + checkStr(temp.getSSJSSJ()) + "','yyyy-MM-dd HH24:mi:ss')," 
					+ "'" + checkStr(temp.getSSJG()) + "'," 
					+ "'" + checkStr(temp.getQTYXCZ()) + "'," 
					
					
					+ "'" + checkStr(temp.getZRLSH()) + "'," 
					+ "'" + checkStr(temp.getORGCODE()) + "'," 
					+ "'" + checkStr(temp.getAREACODE()) + "'," 
					+ "sysdate," 
					+ "'dzbl4'" 
					+ ")\", \"ANNOTION\":\"cdxplogs\"}";
					resule = SentData.sendPost(url, param, userName, password);
					System.out.println(resule);
					
		}
		return resule;
		
	
		
	}
	
	public static String checkStr(Object obj){
		if (obj== null){
			obj = "";
		}
		return (String) obj;
	}
	
	
}
